package com.service.impl;

import com.bean.entity.StudentScoreStatistical;
import com.bean.pojo.PageAssistant;
import com.bean.vo.StudentScoreStatisticalVo;
import com.dao.StudentScoreStatisticalMapper;
import com.service.StudentScoreStatisticalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class StudentScoreStatisticalServiceImpl implements StudentScoreStatisticalService {
    @Autowired
    private StudentScoreStatisticalMapper studentScoreStatisticalMapper;
    @Override
    public int save(StudentScoreStatistical t) throws Exception {
        int insert = studentScoreStatisticalMapper.insert(t);
        if (insert==1) return 1;
        throw new Exception("新增学生信息统计表失败");
    }

    @Override
    public int remove(StudentScoreStatistical t) throws Exception {
        int delete = studentScoreStatisticalMapper.delete(t);
        if (delete==1) return 1;
        throw new Exception("学生信息统计表删除失败");
    }

    @Override
    public int modify(StudentScoreStatistical t) throws Exception {
        int update = studentScoreStatisticalMapper.update(t);
        if (update==1) return 1;
        throw new Exception("学生信息表修改失败");
    }

    @Override
    public StudentScoreStatisticalVo unique(StudentScoreStatistical t) throws Exception {
        return null;
    }

    @Override
    public List<StudentScoreStatisticalVo> query(StudentScoreStatistical t) throws Exception {
        return studentScoreStatisticalMapper.select(t);
    }


    @Override
    public PageAssistant<StudentScoreStatisticalVo> queryByPage(Map<String, Object> map, PageAssistant<StudentScoreStatisticalVo> pa) {
        pa.setCount(studentScoreStatisticalMapper.selectCount(map));

        map.put("startCode",pa.getStartCode());
        map.put("pageSize",pa.getPageSize());

        //查询并添加页面内容
        pa.setItems(studentScoreStatisticalMapper.selectByPage(map));

        return pa;
    }
}
